﻿<!-- #include file="ding.asp" -->
<!-- #include file="mymin.asp" -->
<%
Call Head2
%>
<title>数据库备份恢复</title>
<style type="text/css">
<!--
.STYLE1 {
color: #FFFFFF;
font-weight: bold;
}
.STYLE2 {color: #FF0000}
-->
</style></head><body>
<%
IF KEY<>0 then
	Call Error2("你的权限不足！")
end if

dim db,action,currf,backf,backfy,objfso
db="../#74hucn.mdb"
action=Request.QueryString("action")

If action="back" Then
	currf=request.form("currf")
	currf=server.mappath(currf)
	backf=request.form("backf")
	backf=server.mappath(backf)
	backfy=request.form("backfy")
	On error resume next
	Set objfso = Server.CreateObject("Scripting.FileSystemObject")
	if err then
		err.clear
		Call Error2("不能建立fso对象，请确保你的空间支持fso:！")
	end if
	if objfso.Folderexists(backf) = false then
		Set fy=objfso.CreateFolder(backf)
	end if
	objfso.copyfile currf,backf& "\"& backfy
	Call Error2("备份数据库成功")
End If

If action="ys" Then
	currf=request.form("currf")
	currf = server.mappath(currf)
	dim ys,strDBPath
	ys=request.form("ys")
	Const JET_3X = 4
	strDBPath = left(currf,instrrev(currf,"\"))
	on error resume next
	Set objfso = Server.CreateObject("Scripting.FileSystemObject")
	if err then
		err.clear
		Call Error2("不能建立fso对象，请确保你的空间支持fso:！")
	end if

	if objfso.fileexists(currf) then
		dim Engine
		Set Engine = CreateObject("JRO.JetEngine")
		response.write strDBPath
		on error resume next
		If ys = "1" Then
			Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & currf, _
			"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "tourtemp.mdb;" _
			& "Jet OLEDB:Engine Type=" & JET_3X
		Else
			Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & currf, _
			"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "tourtemp.mdb"
		End If
		objfso.CopyFile strDBPath & "tourtemp.mdb",currf
		objfso.DeleteFile(strDBPath & "tourtemp.mdb")
		Set objfso = nothing
		Set Engine = nothing
		if err then
			err.clear
			Call Error2("错误："&err.description)
		end if
		Call Error2("压缩数据库成功")
	Else
		Call Error2("错误:找不到数据库文件！")
	End If
end if

if action="reload" then
	currf=request.form("currf")
	currf=server.mappath(currf)
	backf=request.form("backf")
	if backf="" then
		Call Error2("请输入您要恢复的数据库全名")
	else
		backf=server.mappath(backf)
	end if
	on error resume next
	Set objfso = Server.CreateObject("Scripting.FileSystemObject")
	if err then
	err.clear
	Call Error2("不能建立fso对象，请确保你的空间支持fso:！")
	end if
	if objfso.fileexists(backf) then
		objfso.copyfile ""&backf&"",""&currf&""
		Call Error2("恢复数据库成功")
	else
		Call Error2("错误:找不到数据库文件！")
	end if
end if
%><form name="form1" method="POST" action="bak.asp?action=back&sid=<%=sid%>">
<div>
<table border="0" cellpadding="3" style="border-collapse: collapse" bordercolor="#111111" width="98%" id="AutoNumber1" cellspacing="3">
<tr>
<td width="100%" bgcolor="#125E03"><span class="STYLE1">备份数据库</span></td>
</tr>
<tr>
<td width="100%" bgcolor="#FBFDFF"></td>
</tr>
<tr>
<td width="100%" bgcolor="#FBFDFF">数据库路径：<br/>
<span style="background-color: #F7FFF7">
<input type="text" name="currf" size="20" value="<%=db%>" readonly><br/>
</span> 备份数据目录：<br/><span style="background-color: #F7FFF7">
<input type="text" name="backf" size="20" value="74huback">
</span></td>
</tr>
<tr>
<td width="100%" bgcolor="#FBFDFF">数据库名称：<br/><span style="background-color: #F7FFF7">
<input type="text" name="backfy" size="20" value="backup.mdb"><br/>
<input type="submit" name="Submit" value="备份" ><br/>
<span class="STYLE2">注：尽量不要更改以上项</span></span></td>
</tr>
</table>
</div>
</form>
<form name="form1" method="POST" action="bak.asp?action=reload&sid=<%=sid%>">
<div>
<table border="0" cellpadding="3" cellspacing="3" style="border-collapse: collapse" bordercolor="#111111" width="98%" id="AutoNumber3">
<tr>
<td width="100%" bgcolor="#125E03">
<span class="STYLE1">恢复数据库</span></td>
</tr>
<tr>
<td width="100%"></td>
</tr>
<tr>
<td width="100%">当前数据库路径：<br/><span style="background-color: #F7FFF7">
<input type="text" name="currf" size="20" value="<%=db%>" readonly>
</span><br/>备份数据库路径：<br/><span style="background-color: #F7FFF7">
<input type="text" name="backf" size="20" value="74huback/backup.mdb"></span><br/>
<span style="background-color: #F7FFF7">
<input type="submit" name="Submit" value="恢复" >
</span>
</td>
</tr>
</table>
</div>
</form>
<a href="74hu/index.asp?sid=<%=sid%>">[站长工具]</a>
<%call rootLast2%>